<?php
/**
 * Eigenes Template
 *
 */
 
m2import("ForumDB.php");
 
class DefaultAction extends phpinchains_WebAction
{

    /**
     * execute method
     */
    function execute (& $env, & $viewmapping, & $actionform)
    {
        $dbaf = new ForumDB($GLOBALS['udba'], $GLOBALS['XICSAppParams']["instance"]);
        $actionform->set("threads", $dbaf->getThreads());
        $actionform->set("params", $GLOBALS['XICSAppParams']);
        $actionform->set("showThreadForm", false);
        if ((checkPermission('appLevel') && checkPermission('add')) || $GLOBALS['XICSAppParams']['mode'] == 3)
        {
            $actionform->set("showThreadForm", true);
        }
        $actionform->set("showThreadDelete", false);
        if ((checkPermission('delete') && checkPermission('appLevel')) || $GLOBALS['XICSAppParams']['mode'] == 3)
        {
            $actionform->set("showThreadDelete", true);
        }
        return 'default';
    }
    /**
     * execute method
     */
    function showThread (& $env, & $viewmapping, & $actionform)
    {
        
    }
    /**
     * execute method
     */
    function addThread (& $env, & $viewmapping, & $actionform)
    {
        if (!$this->validate("default/default", "addThread"))
        {
            return $this->dispatch("default::execute", $actionform);    
        }
        if (((checkPermission('add') && ($GLOBALS['XICSAppParams']['mode'] < 3) 
            && checkPermission('appLevel')) || $GLOBALS['XICSAppParams']['mode'] == 3))
        {
            $dbaf = new ForumDB($GLOBALS['udba'], $GLOBALS['XICSAppParams']["instance"]);
            $dbaf->addThread($actionform->gar("title"), $actionform->gar("description"));
        }
        $this->dispatch("default::execute", $actionform);
    }
    /**
     * execute method
     */
    function delThread (& $env, & $viewmapping, & $actionform)
    {
        if ($actionform->get("threadid") && ($GLOBALS['XICSAppParams']['mode'] == 2)
            && checkPermission('delete') && checkPermission('appLevel'))
        {
            $dbaf = new ForumDB($GLOBALS['udba'], $GLOBALS['XICSAppParams']["instance"]);
            $dbaf->delThread($actionform->get("threadid"));
        }
        $this->dispatch("default::execute", $actionform);
    }

}
?>